import requests
import app


class IhrmApi(object):
    def __init__(self):
        self.url = app.BASE_URL + "/api/sys/login"
        self.headers = app.HEADERS

    def login(self, json_data):
        resp = requests.post(url=self.url, headers=self.headers, json=json_data)
        return resp

    def add_emp(self, headers, req_data):
        resp = requests.post(url=app.BASE_URL + "/api/sys/user",
                             headers=headers, json=req_data)
        return resp

    def query_emp(self, emp_id, headers):
        return requests.get(url=app.BASE_URL + "/api/sys/user/" + emp_id, headers=headers)

    def modify_emp(self, emp_id, headers, req_data):
        return requests.put(url=app.BASE_URL + "/api/sys/user/" + emp_id,
                            headers=headers,
                            json=req_data)

    def delete_emp(self, emp_id, headers):
        return requests.delete(url=app.BASE_URL + "/api/sys/user/" + emp_id,
                               headers=headers)

    def query_emp_list(self, headers):
        return requests.get(url=app.BASE_URL + "/api/sys/user?page=1&size=10",
                            headers=headers)
